import Vue from 'vue'
import VueRouter from 'vue-router'
import LayoutView from '../LayoutView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/index', //打开页面就想显示首页
  },
  {
    path: '/',
    name: 'layout',
    component: LayoutView,
    children: [
       {
         path: 'index',
         name: 'home',
         component: () => import('../views/HomeView.vue')
       },
       {
          path: 'list',
          name: 'list',
          component: () => import('../views/ListView.vue')
        }
        ,
       {
          path: 'my',
          name: 'my',
          component: () => import('../views/MyView.vue')
        }
    ]
  },
  
  {
    path: '/detail',
    name: 'detail',
    component: () => import('../views/DetailView.vue')
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('../views/SearchView.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/LoginView.vue')
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('../views/RegisterView.vue')
  },
  {
    path: '*',
    name: 'error',
    component: () => import('../views/ErrorView.vue')
  },
]

const router = new VueRouter({
  routes
})

export default router
